(function() {
	var a = jQuery;
	ol.ajaxer = function() {
		var b = this;
		this.ajaxer = null;
		this.getOptions = function(c) {
			return {
				data: c.data,
				type: c.type,
				url: c.url,
				timeout: c.timeout > 0 ? c.timeout : undefined,
				async: c.async,
				dataType: c.dataType,
				contentType: "application/x-www-form-urlencoded; charset=UTF-8",
				beforeSend: function() {
					if (typeof(c.beforeSendFunction) == "function") {
						c.beforeSendFunction()
					}
					if (c.button != null) {
						a(c.button).attr("disabled", true)
					}
					if (c.loadingLayer != null) {
						a(c.loadingLayer).css("display", "block")
					}
				},
				success: function(d) {
					if (typeof(c.afterSendFunction) == "function") {
						c.afterSendFunction(d)
					}
					if (c.loadingLayer != null) {
						a(c.loadingLayer).hide()
					}
					if (typeof(c.successFunction) == "function") {
						c.successFunction(d)
					}
					if (c.button != null) {
						a(c.button).attr("disabled", false)
					}
				},
				error: function(e, d) {
					if (typeof(c.afterSendFunction) == "function") {
						c.afterSendFunction(e, d)
					}
					if (c.loadingLayer != null) {
						a(c.loadingLayer).hide()
					}
					if (c.button != null) {
						a(c.button).attr("disabled", false)
					}
					if (d === "timeout" && typeof(c.timeoutFunction) == "function") {
						setTimeout(c.timeoutFunction, 1)
					} else {
						if (typeof(c.errorFunction) == "function") {
							c.errorFunction(e, d)
						}
					}
				}
			}
		};
		this.submit = function(c) {
			c = a.extend({}, ol.ajaxer.settings, c);
			c.type = "POST";
			var d = a(c.form);
			if (c.url) {
				d.attr("action", c.url)
			} else {
				c.url = d.attr("action")
			}
			if (this.ajaxer && typeof(this.ajaxer.abort) == "function") {
				this.ajaxer.abort()
			}
			return this.ajaxer = d.ajaxSubmit(this.getOptions(c))
		};
		this.post = function(c) {
			return this.submit(c)
		}, this.get = function(c) {
			c = a.extend({}, ol.ajaxer.settings, c);
			c.type = "GET";
			if (this.ajaxer && typeof(this.ajaxer.abort) == "function") {
				this.ajaxer.abort()
			}
			return this.ajaxer = a.ajax(this.getOptions(c))
		};
		this.load = function(c) {
			c = a.extend({}, ol.ajaxer.settings, c);
			c.type = "GET";
			c.dataType = "html";
			if (this.ajaxer && typeof(this.ajaxer.abort) == "function") {
				this.ajaxer.abort()
			}
			return this.ajaxer = a.ajax(this.getOptions(c))
		}
	};
	ol.ajaxer.settings = {
		form: "<form></form>",
		type: "post",
		url: null,
		async: true,
		data: {},
		dataType: "json",
		loadingLayer: null,
		button: null,
		beforeSendFunction: null,
		afterSendFunction: null,
		successFunction: null,
		errorFunction: null,
		timeoutFunction: null
	}
})();
ol.ajax = ol.ajaxer;